{extend name="index_layout"/}
{block name="main"}
<div class="layui-card">
    <div class="layui-card-header">角色管理</div>
    <div class="layui-card-body">
        <div class="layui-form">
            <table class="layui-hide" id="currentTable" lay-filter="currentTable"></table>
            <script type="text/html" id="authTool">
                {{#  if(d.id == {$userInfo.roleid}){ }}
                <a class="layui-btn layui-btn-xs layui-btn-danger layui-btn-disabled">不可操作</a>
                {{#  } else { }}
                <a class='layui-btn layui-btn-xs' data-open='{:url("access?group_name=")}?title={{d.title}}&group_id={{d.id}}' title="访问授权">访问授权</a>
                {{#  } }}
            </script>
        </div>
    </div>
</div>
{/block}
{block name="script"}
<script>
layui.use('yznTable', function() {
    var table = layui.yznTable;

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTable',
        add_url: "{:url('createGroup')}",
        edit_url: "{:url('editgroup')}",
        delete_url: "{:url('deletegroup')}",
    };

    table.render({
        init: init,
        toolbar: ['refresh','add'],
        url: '{:url("index")}',
        search:false,
        cols: [
            [
                { field: 'title',width: 200, title: '授权',templet: '#authTool' },
                { field: 'title', width: 200, align: 'left', title: '权限组'},
                { field: 'description', title: '描述' },
                { field: 'status', width: 80,title: '状态',templet: yznTable.formatter.label,selectList:{0:'禁用',1:'正常'}},
                { width:100, title: '操作',templet: function (d){
                    if(d.id=={$userInfo.roleid}){
                        return '<a class="layui-btn layui-btn-xs layui-btn-danger layui-btn-disabled">不可操作</a>';
                    }else{
                        return yznTable.formatter.tool.call(this,d,this);
                    }
                },operat: ['edit','delete']}
            ]
        ],
    });
});
</script>
{/block}